package com.ibiaoke.order.dao;

import com.ibiaoke.common.base.BaseDao;
import com.ibiaoke.order.entity.ShoppingCartGoods;
import com.ibiaoke.order.entity.ShoppingCartGoodsExample;
import com.ibiaoke.order.mapper.ShoppingCartGoodsMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author Dragon
 * @date 2018/5/17/13:26;
 */
@Repository
public class ShoppingCartGoodsDao extends BaseDao<ShoppingCartGoods,ShoppingCartGoodsExample,Integer, ShoppingCartGoodsMapper> {
    @Autowired
    private ShoppingCartGoodsMapper shoppingCartGoodsMapper;


    @Override
    public ShoppingCartGoodsMapper getMapper() {
        return shoppingCartGoodsMapper;
    }

    public List<ShoppingCartGoods> getShoppingCartByCartId(List<Integer> ids) {
        ShoppingCartGoodsExample example = new ShoppingCartGoodsExample();
        example.createCriteria().andShoppingcartIdIn(ids);
        return shoppingCartGoodsMapper.selectByExample(example);
    }

    public List<ShoppingCartGoods> listCartGoods(List<Integer> cartIds, List<Integer> shopIds) {
        ShoppingCartGoodsExample example = new ShoppingCartGoodsExample();
        ShoppingCartGoodsExample.Criteria criteria = example.createCriteria();
        if (cartIds != null) {
            criteria.andShoppingcartIdIn(cartIds);
        }
        if (shopIds != null) {
            criteria.andShopIdIn(shopIds);
        }
        return shoppingCartGoodsMapper.selectByExample(example);
    }
}
